package od_2025B.one;

import java.util.Scanner;

/**
 * https://blog.csdn.net/qq_45776114/article/details/147913914
 * todo 重点在掌握位运算
 */
public class Test02 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String firstLine = scanner.nextLine();
        int respCount = Integer.parseInt(firstLine);
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < respCount; i++) {
            String currentLine = scanner.nextLine();
            int respTime = getRespTime(currentLine);
            min = Math.min(min, respTime);
        }
        scanner.close();
        System.out.println(min);
    }

    /**
     * 获取响应时间
     *
     * @param firstRespLine
     * @return
     */
    private static int getRespTime(String firstRespLine) {
        String[] strArray = firstRespLine.split(" ");
        int receiveRespTime = Integer.parseInt(strArray[0]);
        int respCode = Integer.parseInt(strArray[1]);
        if (respCode < 128) {
            return receiveRespTime + respCode;
        } else {
            String binaryStr = Integer.toBinaryString(respCode);
            int length = binaryStr.length();
            int mant = Integer.parseInt(binaryStr.substring(length - 4), 2);
            int exp = Integer.parseInt(binaryStr.substring(length - 7, length - 4), 2);
            return receiveRespTime + ((mant | 0x10) << (exp + 3));
        }
    }
}
